class D:

    def __setattr__(self, key, value):
        self.__dict__[key] = value

    def __delattr__(self, name):
        print("魔法方法__delattr__被调用了～")
        del self.__dict__[name]


d = D()
d.name = '小甲鱼'
print(d.name)

delattr(d, 'name')
# print(d.name)
